<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('专家转隶申报')" />
</head>
<body class="gray-bg">
    <div class="container-div">
        <div class="row" id="zhuanlishenbao">

            <!--变动申报-->
            <div>
                <div class="col-sm-12 search-collapse">
                    <form id="formId">
                        <div class="select-list">
                            <ul>
                                <li>
                                    <label style="width: 80px !important;">专家&nbsp;&nbsp;</label>
                                    <input style="width: 150px !important;" type="text" name="zhuanjiamingcheng" v-model="zhuanjiamingcheng"/>
                                </li>
                                <li>
                                    <label style="width: 80px !important;">变动类型&nbsp;&nbsp;</label>
                                    <select style="width: 150px !important;" name="biandongleixing" v-model="biandongleixing" class="form-control" type="text">
                                        <option value="8">人事关系转出</option>
                                    </select>
                                </li>
                                <li>
                                    <label style="width: 80px !important;">变动日期&nbsp;&nbsp;</label>
                                    <input style="width: 150px !important;" type="text" class="" placeholder="请选择变动开始日期" name="biandongriqikaishi" id="biandongriqikaishi" v-model="biandongriqikaishi" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" @blur="getDate_chaxun"/>
                                    <input style="width: 150px !important;" type="text" class="" placeholder="请选择变动结束日期" name="biandongriqijieshu" id="biandongriqijieshu" v-model="biandongriqijieshu" onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})" @blur="getDate_chaxun"/>
                                </li>
                                <li class="sousuo">
                                    <a class="btn btn-success btn-md" @click="bindBiandongList"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                    <a class="btn btn-warning btn-md" @click="refresh"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                                </li>
                            </ul>
                        </div>
                    </form>
                </div>

                <div class="col-sm-12 select-table table-striped">

                    <div style="display: flex">
                        <div class="btn-group-md" id="toolbar" role="group">
                            <button class="btn btn-primary dim" @click="toAdd">
                                <i class="fa fa-plus"></i> 新增专家转隶信息
                            </button>
<!--                            <button class="btn btn-warning dim">
                                <i class="fa fa-download"></i> 导出
                            </button>-->
                        </div>
                    </div>

                    <!--列表-->
                    <table id="bootstrap-table" class="table table-hover table-primary table-striped" style="margin-top: 10px;grid-column: 1/-1;grid-row: 2;">
                        <thead>
                            <tr>
                                <th style="text-align: center; vertical-align: middle;">序号</th>
                                <th style="text-align: center; vertical-align: middle;">专家代码</th>
                                <th style="text-align: center; vertical-align: middle;">专家</th>
                                <th style="text-align: center; vertical-align: middle;">证件号码</th>
                                <th style="text-align: center; vertical-align: middle;">入选年份</th>
                                <th style="text-align: center; vertical-align: middle;">出生日期</th>
                                <th style="text-align: center; vertical-align: middle;">转自单位</th>
                                <th style="text-align: center; vertical-align: middle;">转至单位</th>
                                <th style="text-align: center; vertical-align: middle;">变动日期</th>
                                <th style="text-align: center; vertical-align: middle;">状态</th>
                                <th style="text-align: center; vertical-align: middle;">操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr v-for="(biandongitem,index) in biandonglist"  v-if="biandonglist.length > 0">
                                <td style="vertical-align: middle; text-align: center;" v-text="index+1"></td>
                                <td style="vertical-align: middle; text-align: center;" v-text="biandongitem.zhuanjiaid"></td>
                                <td style="vertical-align: middle; text-align: center;" v-text="biandongitem.xingming"></td>
                                <td style="vertical-align: middle; text-align: center;" v-text="biandongitem.zhengjianhaoma"></td>
                                <td style="vertical-align: middle; text-align: center;" v-text="biandongitem.ruxuannianfen"></td>
                                <td style="vertical-align: middle; text-align: center;" v-text="biandongitem.chushengriqi"></td>
                                <td style="vertical-align: middle; text-align: center;" v-text="biandongitem.zhuanli_zhuanchudanweimingcheng"></td>
                                <td style="vertical-align: middle; text-align: center;" v-text="biandongitem.zhuanli_zhuanrudanwei"></td>
                                <td style="vertical-align: middle; text-align: center;" v-text="biandongitem.biandongshijian"></td>
                                <td style="vertical-align: middle; text-align: center;color:blue;" v-if="biandongitem.isqidong==0">未提交</td>
                                <td style="vertical-align: middle; text-align: center;color:orange;" v-if="biandongitem.isqidong==1&&biandongitem.isjieshu==0">审核中</td>
                                <td style="vertical-align: middle; text-align: center;color:green;" v-if="biandongitem.isqidong==1&&biandongitem.isjieshu==1">已接收</td>
                                <td style="vertical-align: middle; text-align: center;color:red;" v-if="biandongitem.isjieshu==1&&biandongitem.beizhu2==2">不通过</td>
                                <td style="vertical-align: middle; text-align: center;color:green;" v-if="biandongitem.isjieshu==1&&biandongitem.beizhu2==1">通过</td>
                                <td style="vertical-align: middle; text-align: center;" v-text="">
                                    <!--<button v-if="biandongitem.isqidong==0||biandongitem.isqidong==null" class="btn btn-warning btn-md" @click="toModify(biandongitem.shenbaoid)">修改</button>-->
                                    <button v-if="biandongitem.isqidong==0||biandongitem.isqidong==null" class="btn btn-danger btn-md" @click="Delete(biandongitem.shenbaoid)">删除</button>
                                    <button v-if="biandongitem.isqidong==0||biandongitem.isqidong==null" class="btn btn-primary btn-md" @click="Submit(biandongitem.shenbaoid)">提交</button>
                                    <button v-if="biandongitem.isqidong==1" class="btn btn-info btn-md" @click="showShenhejiluModel(biandongitem.shiwuid)">审核进度</button>
                                </td>
                            </tr>
                            <tr v-if="biandonglist.length == 0">
                                <td style="text-align: center; vertical-align: middle" colspan="11">查无数据</td>
                            </tr>
                        </tbody>
                    </table>
                    <!--翻页-->
                    <div v-if="recordCount != '0'" class="my-page-navigation" style="text-align:center;margin-left: auto;">
                        <button class="btn btn-default" @click="firstPage">首页</button>
                        <button class="btn btn-default" @click="prePage">上一页</button>
                        <select class="custom-select border-secondary" v-model="pagesize">
                            <option value="10">10 条/页</option>
                            <option value="20">20 条/页</option>
                            <option value="30">30 条/页</option>
                            <option value="50">50 条/页</option>
                        </select>
                        <span v-text="pageindex + '  /  ' + pageCount" style="border-color: #6c757d"></span>
                        <span v-text="'共' + recordCount + '条'" style="border-color: #6c757d"></span>
                        <button class="btn btn-default" @click="nextPage">下一页</button>
                        <button class="btn btn-default" @click="lastPage">尾页</button>
                        <span style="border-color: #6c757d">跳到第</span>
                        <input type="text" class="form-control border-secondary" style="width:50px;display:inline;" v-model="targetpage" @keyup.enter="targetPage">
                        <span style="border-color: #6c757d">页</span>
                        <button class="btn btn-default" @click="targetPage">跳</button>
                    </div>
                </div>
            </div>

            <!-- 审核记录-->
            <div th:replace="system/zhuanjia/modal_shenhejilu::shenhejilu"></div>
            <!-- 编辑专家转隶信息 -->
            <div th:replace="system/zhuanjia/modal_zhuanliedit::modal_zhuanliedit"></div>

        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: WdatePicker" />
    <script th:src="@{/js/plupload/plupload.js?v=1.0}"></script>
    <script th:src="@{/js/plupload/plupload.full.js?v=1.0}"></script>
    <script th:src="@{/js/upload_fujian.js?v=1.1}"></script>
    <script>

        $(function() {
            InitUpLoader();
        });

        var vm_zhuanlishenbao = new Vue({
            el : "#zhuanlishenbao",
            data : {
                deptid : $("#deptid").val(),		// 单位ID
                deptname : $("#deptname").val(),		// 单位ID

                //查询用字段
                zhuanjiamingcheng : '',
                zhuanrudanwei : '',
                biandongleixing : '8',
                biandongriqikaishi : '',
                biandongriqijieshu : '',

                biandonglist : [],//专家变动列表
                zhuanjialist : [],//本单位专家列表
                shenhejilulist : [],//审核记录
                zhuanrudanweilist : [],//转入单位列表

                biandong : {},//变动申报对象

                pageindex : 1,		// 查询分页初始化页
                pagesize : 10,		// 查询分页初始化页面大小
                pageCount : 0,		// 总页数
                recordCount : 0,	// 总记录数
                targetpage : '', 	// 目标页

                //编辑框
                zhuanjianame : '',//查询专家名字

                editflag : '',//1添加 2修改
            },
            created : function(){
                var _this = this;

                _this.bindZhuanjiaList();
                _this.bindBiandongList();
                _this.BindZhuanrudanwei();
            },
            watch : {
            },
            methods : {

                //查询所有单位
                BindZhuanrudanwei:function(){
                    var _this = this;

                    $.post('/system/deptxinxi/customlist', {
                        deptname : _this.zhuanrudanwei,
                        rdm : Math.random()
                    },function(ppData) {

                        if (ppData != null) {
                            var data = ppData.resultContent;

                            _this.zhuanrudanweilist = data;
                        }
                    },"json");
                },

                // 根据单位ID查询专家变动申请信息
                bindBiandongList : function(){
                    var _this = this;

                    var biandong_layer = layer.open({type:3});
                    $.post('/system/biandongshenbao/custombiandonglist', {
                        deptid : _this.deptid,
                        zhuanjiamingcheng : _this.zhuanjiamingcheng,
                        biandongleixing : _this.biandongleixing,
                        biandongriqikaishi : _this.biandongriqikaishi,
                        biandongriqijieshu : _this.biandongriqijieshu,
                        pageindex : _this.pageindex,
                        pagesize : _this.pagesize,
                        rdm : Math.random()
                    },function(ppData) {
                        layer.close(biandong_layer);

                        if (ppData != null) {
                            var data = ppData.resultContent;
                            _this.biandonglist = data.biandonglist;

                            var pageInfo = data.PageInfo;
                            _this.pageindex = pageInfo.pageIndex;
                            _this.pageCount = pageInfo.pageCount;
                            _this.recordCount = pageInfo.recordCount;
                            _this.targetpage = '';
                        }
                    },"json");
                },

                //首页
                firstPage : function(){
                    this.pageindex = 1;
                },
                //尾页
                lastPage : function(){
                    this.pageindex = this.pageCount;
                },
                //上一页
                prePage : function(){
                    var prePage = ((this.pageindex -1) <= 0) ? 1 : (this.pageindex -1);
                    this.pageindex = prePage;
                },
                //下一页
                nextPage : function(){
                    var nextPage = ((this.pageindex +1) >= this.pageCount) ? this.pageCount : (this.pageindex +1);
                    this.pageindex = nextPage;
                },
                //跳到目标页
                targetPage : function() {
                    if( this.targetpage != '' && this.targetpage <= this.pageCount && this.targetpage > 0){
                        this.pageindex = this.targetpage;
                        this.targetpage = '';
                    }
                },

                getZhuanrudanwei:function(){
                    this.biandong.zhuanrudanwei=$("#zhuanrudanwei").val();
                },

                //绑定专家列表
                bindZhuanjiaList : function(){
                    var _this = this;

                    var biandong_layer = layer.open({type:3});
                    $.post('/system/zhuanjiadept/findbydeptid', {
                        deptid : _this.deptid,
                        zhuanjianame : _this.zhuanjianame,
                        rdm : Math.random()
                    },function(ppData) {
                        layer.close(biandong_layer);

                        if (ppData != null) {
                            var data = ppData;
                            _this.zhuanjialist = data;
                        }
                    },"json");
                },

                toAdd:function(){
                    var _this = this;

                    $("#myModalLabel").html("新增专家转隶申报");
                    $("#modal-dialog").attr("style", "width:1200px;");
                    $("#zhuanliModal").modal();

                    //编辑框专家搜索置空
                    _this.zhuanjianame = '';
                    //绑定本单位专家
                    _this.bindZhuanjiaList();

                    //变动置空
                    _this.biandong = {};
                    _this.biandong.biandongleixing = '8';

                    //上传附件
                    $("#fujianurl1").val("");
                    $("#filelist1").empty();

                    //编辑标记
                    _this.editflag = 1;
                },

                //添加
                add:function(){
                    var _this = this;
                    if (_this.checkInputData()) {
                        var biandong_layer = layer.open({type: 3});
                        $.post('/system/biandongshenbao/save', {
                            //shenbao
                            biandongleixing:_this.biandong.biandongleixing,
                            biandongshijian:_this.biandong.biandongshijian,
                            zhuanjiaid:_this.biandong.zhuanjiaid,
                            deptid:_this.deptid,
                            //zhuanli
                            zhuanchushijian:_this.biandong.biandongshijian,
                            zhuanchudanwei:_this.deptid,
                            zhuanchulianxiren:_this.biandong.zhuanchulianxiren,
                            zhuanchudianhua:_this.biandong.zhuanchudianhua,
                            shuoming:_this.biandong.shuoming,
                            zhuanrudanwei:_this.biandong.zhuanrudanwei,
                            zhuanrulianxiren:_this.biandong.zhuanrulianxiren,
                            zhuanrudianhua:_this.biandong.zhuanrudianhua,
                            //fujian
                            filepath : $("#fujianurl").val(),
                            yuanyin : '',
                            rdm: Math.random()
                        }, function (ppData) {
                            layer.close(biandong_layer);
                            if (ppData != null) {
                                if (ppData.result == "1") {
                                    layer.open({
                                        time: 1000,
                                        btn: [],
                                        content: "新增成功!",
                                    });
                                    _this.bindBiandongList();
                                    $("#zhuanliModal").modal('hide');
                                } else {
                                    layer.alert(ppData.message);
                                }
                            }
                        }, "json");
                    }
                },

                Delete:function(id){
                    var _this = this;

                    if (confirm("是否删除专家转隶？")) {
                        var biandong_layer = layer.open({type: 3});
                        $.post('/system/biandongshenbao/remove', {
                            ids: id,
                            rdm: Math.random()
                        }, function (ppData) {
                            layer.close(biandong_layer);

                            var result = ppData.code;
                            if (result == 0) {
                                layer.open({
                                    time: 1000,
                                    btn: [],
                                    content: "删除成功!",
                                });
                                // _this.bindQushiList();
                                _this.bindBiandongList();
                                //location.reload();
                            } else {
                                layer.alert(ppData.msg);
                            }
                        }, "json");
                    }
                },

                Submit:function(id){
                    var _this = this;

                    var biandong_layer = layer.open({type:3});
                    $.post('/system/renwu/submit_custom', {
                        id : id,
                        deptid : _this.deptid,
                        rdm : Math.random()
                    },function(ppData) {
                        layer.close(biandong_layer);

                        if (ppData != null) {
                            var result = ppData.result;
                            if (result==="1"){
                                layer.alert("提交成功！");
                                _this.bindBiandongList();
                            }else{
                                layer.alert(ppData.message);
                            }
                        }
                    },"json");
                },

                /*工具*/
                checkInputData:function(){
                    return true;
                },

                refresh:function(){
                    var _this = this;
                    _this.zhuanjiamingcheng = '';
                    _this.biandongriqikaishi = '';
                    _this.biandongriqijieshu = '';
                },

                getDate_chaxun:function(){
                    var _this = this;

                    _this.biandongriqikaishi=$("#biandongriqikaishi").val();
                    _this.biandongriqijieshu=$("#biandongriqijieshu").val();
                },

                getDate_biandongshijian:function(){
                    var _this = this;
                    _this.biandong.biandongshijian=$("#zhuanchushijian").val();
                    _this.biandong.zhuanchushijian=$("#zhuanchushijian").val();
                },

                showShenhejiluModel:function(ppShiwuId){
                    var _this = this;

                    $("#shenhejiluModalLabel").html("审核进度");
                    $("#shenhejiluModal").modal();

                    _this.bindShenhejilu(ppShiwuId);
                },

                bindShenhejilu:function(ppShiwuId){
                    var _this = this;

                    var biandong_layer = layer.open({type:3});
                    $.post('/system/renwu/findspjl', {
                        shiwuid : ppShiwuId,
                        rdm : Math.random()
                    },function(ppData) {
                        layer.close(biandong_layer);

                        if (ppData != null) {
                            var data = ppData;
                            _this.shenhejilulist = data.resultContent;
                        }
                    },"json");
                },

            },
        })
    </script>
</body>
</html>